<template name="searchBar">
	<view class="topFixed">
		<statusBar></statusBar>
		<view class="hksearchbar">
			<view class="leftBox" data-url="selectCity" @tap="toPage">
				<image src="../../static/index/adds.png"></image>
				<text>{{selectCity.cityName}}</text>
			</view>
			<view class="searchBox" data-url="search" @tap="toPage">
				<text class="iconfont icon-search"></text>
				<text>请输入课程</text>
			</view>
			<view class="rightBox">
				<image src="../../static/index/car.png" @tap="toCar"></image>
			</view>
		</view>
	</view>
</template>

<script>
	import statusBar from "../statusBar/statusBar.vue";
	import {
		mapState,
		mapGetters,
		mapMutation,
		mapActions
	} from "vuex";
	export default {
		components:{statusBar},
		computed: {
			...mapState({
				userInfo: state => state.user.userInfo,
				isLogin:state=>state.user.isLogin,
				locationCity:state=>state.map.locationCity,
				selectCity:state=>state.map.selectCity
			})
		
		},
		name: 'searchBar',
		props: {
			iconColor: {
				type: String,
				default: '#000000'
			},


		},
		data(){
			return{
				stsHeight:uni.getSystemInfoSync().statusBarHeight,
				city:'南京'
			}
		},
		methods: {
			toCar(){
				if(this.isLogin){
					this.toPage("car")
				}else{
					// this.toPage("login")
				    this.$parent.open();
				}
			}
		},
		created() {
			setTimeout(()=>{
				let query = uni.createSelectorQuery().in(this);
				query.select('.topFixed').boundingClientRect(data => {
					getApp().globalData.G_SEARCHBAR=data
				}).exec();
				this.city=this.locationCity.city
			},100)
		}
	}
</script>

<style lang="less">
	@import "../../common/public.less";

	.topFixed {
		position: fixed;
		width: 100%;
		z-index: 990;
		top: 0;
		left: 0;
		background-color: @color-m;
	}

	.hksearchbar {
		padding: 15rpx 28rpx;
		display: flex;
		align-items: center;
		height: 90upx;
		/* #ifdef MP */
		padding-right: 30%;
		/* #endif */

		.leftBox {
			height: 100%;
			display: flex;
			flex-grow: 0;
			flex-shrink: 0;
			align-items: center;
			margin-right: 16rpx;

			image {
				width: 25rpx;
				height: 36rpx;
				display: block;
				margin-right: 10rpx;
			}

			text {
				font-family: MicrosoftYaHei;
				font-size: 36rpx;
				font-stretch: normal;
				color: #07080d;
			}

		}

		.rightBox {
			height: 100%;
			display: flex;
			flex-grow: 0;
			flex-shrink: 0;
			align-items: center;
			margin-left: 16rpx;
			image {
				width: 48rpx;
				height: 44rpx;
				display: block;
			}
		}

		.searchBox {
			display: flex;
			height: 60rpx;
			border-radius: 30rpx;
			background-color: #FFFFFF;
			display: flex;
			align-items: center;
			flex-grow: 1;
			padding: 0 30rpx;
			/* #ifdef MP */
			padding: 0 24rpx;
			/* #endif */
			text{
				font-size: 26rpx;
				color: #aeb5bf;
				margin-right: 14rpx;
			}
		}

	}
</style>
